// @FileName  :comment.c
// @Time      :2024/3/1 0:12
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main() {
    FILE *file = fopen("filein.c", "r");
    fseek(file, 0, SEEK_END);
    long fileSize = ftell(file);
    fseek(file, 0, SEEK_SET);
    char *buffer = (char *) malloc(fileSize + 1);
    fread(buffer, 1, fileSize, file);
    buffer[fileSize] = '\0';
    fclose(file);
    int commentChars = 0;
    int inComment = 0;
    for (int i = 0; i < fileSize; i++) {
        if (buffer[i] == '/' && (i + 1 < fileSize && buffer[i + 1] == '*')) {
            inComment = 1;
            i++;
        } else if (buffer[i] == '*' && (i + 1 < fileSize && buffer[i + 1] == '/')) {
            inComment = 0;
            i++;
        } else if (inComment) {
            commentChars++;
        }
    }
    int percentage = (commentChars * 100) / fileSize;
    printf("%d%%\n", percentage);
    free(buffer);
    return 0;
}